package test.core.safe;

import java.security.Key;

import javax.crypto.spec.IvParameterSpec;

import org.junit.Test;

import hyl.core.MyFun;
import hyl.core.safe.MyAes;
import hyl.core.safe.MyDes;
import hyl.core.safe.MySecret;

public class test {
	//@Test
	public void testkey() {
		Key key = MySecret.createKey("AES", "0414096238261");
		System.out.println("---------");
		System.out.println(key);
		System.out.println("---------");
	}
	@Test
	public void aes1() {
		String 明文 = MyFun.join2(",", "100000", "111111");
		// String 明文 = "芸swee看ad付款是的发~!#$$#&#&^^%**() {}:>?<|送的合并t2";
		System.out.println(明文);
		// System.out.println(明文.getBytes().length);
		String key = "0414096238261";
		//Key k = MyAes.generateKey(key);
		Key k = MySecret.createKey("AES", key);
		String s = MyAes.f加密64(明文, k);
		System.out.println(s);
		String s2 = MyAes.f解密64(s, k);
		System.out.println(s2);
	}

	// @Test
	public void aes2() throws Exception {

		String 明文 = MyFun.join2(",", "100000", "111111");
		// String 明文 = "芸swee看ad付款是的发~!#$$#&#&^^%**() {}:>?<|送的合并t2";
		System.out.println(明文);
		// System.out.println(明文.getBytes().length);
		String key = "0414096238261";
		Key k = MyAes.generateKey(key);
		IvParameterSpec iv = MyAes.generateIv("hylzdy37798955qq");
		byte[] s = MyAes.f加密(明文.getBytes(), k, iv);
		byte[] s2 = MyAes.f解密(s, k, iv);
		System.out.println(new String(s2));
	}

	// @Test
	public void des2() throws Exception {
		String 明文 = "在下次V3a396c0fc74cd2bb295d3a9a807f15,1,814013d57b0e4a0689e60e2e869ed6e7,5608542655261,127.0.0.1";
		// String 明文 = "芸swee看ad付款是的发~!#$$#&#&^^%**() {}:>?<|送的合并t2";
		System.out.println(明文);
		// System.out.println(明文.getBytes().length);
		String key = "com.sevenlin.foo.foo.foo";
		Key k = MyDes.generateKey(key);
		byte[] s = MyDes.f加密(明文.getBytes(), k);
		byte[] s2 = MyDes.f解密(s, k);
		System.out.println(new String(s2));
	}

	 @Test
	public void des1() throws Exception {
		String 明文 = "在啊时代发生的话0fc74cd2bb295d3a9a807f15,1,814013d57b0e4a0689e60e2e869ed6e7,5608542655261,127.0.0.1";
		// String 明文 = "芸swee看ad付款是的发~!#$$#&#&^^%**() {}:>?<|送的合并t2";
		System.out.println(明文);
		// System.out.println(明文.getBytes().length);
		String key = "0414096238261";
		Key k = MyDes.generateKey(key);
		String s = MyDes.f加密64(明文, k);
		String s2 = MyDes.f解密64(s, k);
		System.out.println(s2);
	}
}
